diff --git a/app/config/routes.php b/app/config/routes.php index f8a56c7..adcd071 100644 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -34,6 +34,7 @@ return [ 'default_controller' => 'welcome', 'default_module' => 'meta', 'genre' => 'meta/genre/index', + 'genre/add' => 'meta/genre/add', 'genre/add_category' => 'meta/genre/add_category', 'category' => 'meta/category/index', 'category/add_section' => 'meta/category/add_section', diff --git a/app/modules/meta/controllers/category.php b/app/modules/meta/controllers/category.php index 32266ea..4a05575 100644 --- a/app/modules/meta/controllers/category.php +++ b/app/modules/meta/controllers/category.php @@ -74,7 +74,7 @@ class category extends meta\controller { $this->page->set_message('error', 'Section already exists for this category'); } - $this->detail($id); + $this->index($id); } } diff --git a/app/modules/meta/controllers/genre.php b/app/modules/meta/controllers/genre.php index 19f3133..144460e 100644 --- a/app/modules/meta/controllers/genre.php +++ b/app/modules/meta/controllers/genre.php @@ -97,6 +97,9 @@ class genre extends meta\controller { $this->load_view('genre_detail', $data); } + /** + * Adds a category to the current genre + */ public function add_category() { // Strip away tags for the sake of security diff --git a/app/modules/meta/controllers/section.php b/app/modules/meta/controllers/section.php index 04d572b..f13a59d 100644 --- a/app/modules/meta/controllers/section.php +++ b/app/modules/meta/controllers/section.php @@ -62,7 +62,10 @@ class section extends meta\controller { $keys = filter_var_array($_POST['name'], FILTER_SANITIZE_STRING); - $vals = filter_var_array($_POST['val'], FILTER_SANITIZE_STRING); + + // Raw to allow use of HTML formatting + // Prepared statements keep the database safe here. + $vals = $_POST['val']; $data = array_combine($keys, $vals); diff --git a/app/modules/meta/models/model.php b/app/modules/meta/models/model.php index c5a31ff..f3a0e9a 100644 --- a/app/modules/meta/models/model.php +++ b/app/modules/meta/models/model.php @@ -106,8 +106,8 @@ class model extends \miniMVC\Model { // Fetch the data as a workaround // for databases that do not support // grabbing result counts (SQLite / Firebird) - $array = $query->fetchAll(); - if (empty($array)) + $array = $query->fetchAll(\PDO::FETCH_ASSOC); + if (count($array) < 1) { $this->db->set('genre', $genre) ->insert('genre'); diff --git a/app/modules/meta/views/category_detail.php b/app/modules/meta/views/category_detail.php index 8e7e0be..2415262 100644 --- a/app/modules/meta/views/category_detail.php +++ b/app/modules/meta/views/category_detail.php @@ -13,7 +13,7 @@
-
+ @@ -23,6 +23,10 @@
  • ">

    + + + + @@ -30,7 +34,10 @@ ") !== FALSE) ? 'multiline' : 'pair' ?>
    -
    +
    + + +
    diff --git a/app/modules/meta/views/genre_detail.php b/app/modules/meta/views/genre_detail.php index caab403..8049090 100644 --- a/app/modules/meta/views/genre_detail.php +++ b/app/modules/meta/views/genre_detail.php @@ -13,14 +13,20 @@
    -
    + diff --git a/app/modules/meta/views/genres.php b/app/modules/meta/views/genres.php index 85cce01..603f4f7 100644 --- a/app/modules/meta/views/genres.php +++ b/app/modules/meta/views/genres.php @@ -9,13 +9,21 @@
     
    -
    + \ No newline at end of file diff --git a/app/modules/meta/views/section_detail.php b/app/modules/meta/views/section_detail.php index cc00275..17c13aa 100644 --- a/app/modules/meta/views/section_detail.php +++ b/app/modules/meta/views/section_detail.php @@ -16,10 +16,10 @@
    -
    +
    -
    + diff --git a/assets/config/config.php b/assets/config/config.php index 2f44507..c1748dd 100755 --- a/assets/config/config.php +++ b/assets/config/config.php @@ -13,6 +13,7 @@ // -------------------------------------------------------------------------- + /** * Asset management configuration file * @@ -53,7 +54,7 @@ $css_root = $document_root. 'css/'; | Path fragment to rewrite in css files | */ -$path_from = ''; +$path_from = './images/'; /* |-------------------------------------------------------------------------- @@ -63,7 +64,7 @@ $path_from = ''; | The path fragment replacement for the css files | */ -$path_to = ''; +$path_to = '//github.timshomepage.net/meta/assets/images/'; /* |-------------------------------------------------------------------------- diff --git a/assets/config/css_groups.php b/assets/config/css_groups.php index cb100fe..2113b50 100644 --- a/assets/config/css_groups.php +++ b/assets/config/css_groups.php @@ -23,7 +23,8 @@ return array( 'css' => array( 'normalize.css', 'message.css', - 'theme.css' + 'theme.css', + 'tinyeditor.css' ) ); // End of css_groups.php \ No newline at end of file diff --git a/assets/config/js_groups.php b/assets/config/js_groups.php index 811ef79..663235a 100755 --- a/assets/config/js_groups.php +++ b/assets/config/js_groups.php @@ -28,6 +28,7 @@ return array( 'js' => array( 'kis-lite-dom-min.js', + 'tinyeditor.js', 'meta.js' ), ); \ No newline at end of file diff --git a/assets/css.php b/assets/css.php index c6059ab..44bc32d 100755 --- a/assets/css.php +++ b/assets/css.php @@ -113,6 +113,10 @@ if ($last_modified === $requested_time) exit(); } +// Correct paths that have changed due to concatenation +// based on rules in the config file +$css = str_replace($path_from, $path_to, $css); + if (!isset($_GET['debug'])) { $css = compress($css); diff --git a/assets/css/theme.css b/assets/css/theme.css index d939611..5722b0d 100644 --- a/assets/css/theme.css +++ b/assets/css/theme.css @@ -11,6 +11,10 @@ html, body { button { color:#312; + padding:5px; + border:1px solid #555; + border-radius:5px; + box-shadow:1px 1px #a98; } a { @@ -30,7 +34,6 @@ legend:hover { } h1,h2 { - display:-moz-inline-box; display:inline-block; vertical-align:middle; width:25%; @@ -43,8 +46,8 @@ fieldset dl { /* form styles */ form dt, form dd { - display:-moz-inline-box; /* For older versions of Mozilla/Firefox */ display:inline-block; + vertical-align:top; padding:0.25em 0; } @@ -60,7 +63,40 @@ form dd { padding-left:.25em; } -/* Outline styles */ +/* ! Edit buttons */ +.modify { + position:absolute; + display:none; + margin-left:1em; +} + +li:hover .modify, dt:hover .modify { + display:inline-block; +} + +button.save { + background:#797; + color:#eee; +} + +button.save:hover { + background:#595; +} + +button.edit { + +} + +button.delete { + background:#977; + color:#eee; +} + +button.delete:hover { + background:#955; +} + +/* ! Outline styles */ .list { padding:0; margin:0; @@ -74,7 +110,11 @@ form dd { list-style:none; } -/* Data listing styles */ +li h4 { + display:inline; +} + +/* ! Data listing styles */ dl.multiline, dl.pair { border-bottom:1px dotted #312; } @@ -92,7 +132,6 @@ dl.multiline dd { } dl.pair dt, dl.pair dd { - display:-moz-inline-block; display:inline-block; padding:0.25em 0; } diff --git a/assets/css/tinyeditor.css b/assets/css/tinyeditor.css new file mode 100755 index 0000000..af30fb8 --- /dev/null +++ b/assets/css/tinyeditor.css @@ -0,0 +1,57 @@ +.te { + border: 1px solid #bbb; + padding: 0 1px 1px; + font: 12px Verdana,Arial; +} + .te iframe { border: none } +.teheader { + height: 31px; + border-bottom: 1px solid #bbb; + background: url(./images/header-bg.gif) repeat-x; + padding-top: 1px; + overflow: hidden; +} +.testyle { margin-right: 12px } +.tedivider { + float: left; + width: 1px; + height: 30px; + background: #ccc; +} +.tecontrol { + float: left; + width: 34px; + height: 30px; + cursor: pointer; + background-image: url(./images/icons.png); +} +.tecontrol:hover { + background-color: #fff; + background-position: 30px 0; +} +.tefooter { + height: 32px; + border-top: 1px solid #bbb; + background: #f5f5f5; +} +.toggle { + float: left; + background: url(./images/icons.png) -34px 2px no-repeat; + padding: 9px 13px 0 31px; + height: 23px; + border-right: 1px solid #ccc; + cursor: pointer; + color: #666; +} +.toggle:hover { background-color: #fff } +.resize { + float: right; + height: 32px; + width: 32px; + background: url(./images/resize.gif) 15px 15px no-repeat; + cursor: s-resize; +} +#editor { + cursor: text; + margin: 10px; +} \ No newline at end of file diff --git a/assets/images/header-bg.gif b/assets/images/header-bg.gif new file mode 100755 index 0000000..a23a14d Binary files /dev/null and b/assets/images/header-bg.gif differ diff --git a/assets/images/icons.png b/assets/images/icons.png new file mode 100755 index 0000000..e88b564 Binary files /dev/null and b/assets/images/icons.png differ diff --git a/assets/images/resize.gif b/assets/images/resize.gif new file mode 100755 index 0000000..385ec27 Binary files /dev/null and b/assets/images/resize.gif differ diff --git a/assets/js/cache/js b/assets/js/cache/js index 215d404..f61d7b4 100644 --- a/assets/js/cache/js +++ b/assets/js/cache/js @@ -1,17 +1,34 @@ -(function(){if("undefined"!==typeof document.querySelector){var d,e,b,c;d=function(a){c="undefined"===typeof a?"undefined"!==typeof d.el?d.el:document.documentElement:"object"!==typeof a?e(a):a;d.prototype.el=c;var a=b(d),f;for(f in a)"object"===typeof a[f]&&(a[f].el=c);a.el=c;return a};e=function(a,f){var b;if("string"!=typeof a||"undefined"===typeof a)return a;b=null!=f&&1===f.nodeType?f:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);b=b.querySelectorAll(a); -return 1===b.length?b[0]:b};b=function(a){var f;if("undefined"!==typeof a){if("undefined"!==typeof Object.create)return Object.create(a);f=typeof a;if(!("object"!==f&&"function"!==f))return f=function(){},f.prototype=a,new f}};d.ext=function(a,f){f.el=c;d[a]=f};d.ext("each",function(a){if("undefined"!==typeof c.length&&c!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(c,a);else{var f=c.length;if(0!==f)for(var b,d=0;d"],["Header 1","

    "],["Header 2","

    "],["Header 3","

    "],["Header 4","

    "],["Header 5","

    "],["Header 6","
    "]];k=m.length;h=0; +g.className="testyle";g.onchange=new Function(this.n+'.ddaction(this,"formatblock")');for(h;h";f=a.bodyid?' id="'+a.bodyid+'"':"";a.cssfile&&(b+='');a.css&&(b+='"); +b+=""+(a.content||this.t.value);this.e.write(b+"");this.e.close();this.e.designMode="on";this.d=1;if(this.xhtml)try{this.e.execCommand("styleWithCSS",0,0)}catch(p){try{this.e.execCommand("useCSS",0,1)}catch(q){}}}var e=[],d=-30;e.cut=[1,"Cut","a","cut",1];e.copy=[2,"Copy","a","copy",1];e.paste=[3,"Paste","a","paste",1];e.bold=[4,"Bold","a","bold"];e.italic=[5,"Italic","a","italic"];e.underline=[6,"Underline","a","underline"];e.strikethrough=[7,"Strikethrough","a","strikethrough"]; +e.subscript=[8,"Subscript","a","subscript"];e.superscript=[9,"Superscript","a","superscript"];e.orderedlist=[10,"Insert Ordered List","a","insertorderedlist"];e.unorderedlist=[11,"Insert Unordered List","a","insertunorderedlist"];e.outdent=[12,"Outdent","a","outdent"];e.indent=[13,"Indent","a","indent"];e.leftalign=[14,"Left Align","a","justifyleft"];e.centeralign=[15,"Center Align","a","justifycenter"];e.rightalign=[16,"Right Align","a","justifyright"];e.blockjustify=[17,"Block Justify","a","justifyfull"]; +e.undo=[18,"Undo","a","undo"];e.redo=[19,"Redo","a","redo"];e.image=[20,"Insert Image","i","insertimage","Enter Image URL:","http://"];e.hr=[21,"Insert Horizontal Rule","a","inserthorizontalrule"];e.link=[22,"Insert Hyperlink","i","createlink","Enter URL:","http://"];e.unlink=[23,"Remove Hyperlink","a","unlink"];e.unformat=[24,"Remove Formatting","a","removeformat"];e.print=[25,"Print","a","print"];f.prototype.print=function(){this.i.contentWindow.print()};f.prototype.hover=function(c,a,b){c.style.backgroundPosition= +(b?"34px ":"0px ")+a+"px"};f.prototype.ddaction=function(c,a){this.action(a,c.options[c.selectedIndex].value)};f.prototype.action=function(c,a,b){b&&!this.ie?alert("Your browser does not support this function."):this.e.execCommand(c,0,a||null)};f.prototype.insert=function(c,a,b){c=prompt(c,a);null!=c&&""!=c&&this.e.execCommand(b,0,c)};f.prototype.setfont=function(){execCommand("formatblock",0,hType)};f.prototype.resize=function(c){this.mv&&this.freeze();this.i.bcs=TINY.cursor.top(c);this.mv=new Function("event", +this.n+".move(event)");this.sr=new Function(this.n+".freeze()");this.ie?(document.attachEvent("onmousemove",this.mv),document.attachEvent("onmouseup",this.sr)):(document.addEventListener("mousemove",this.mv,1),document.addEventListener("mouseup",this.sr,1))};f.prototype.move=function(c){c=TINY.cursor.top(c);this.i.height=parseInt(this.i.height)+c-this.i.bcs;this.i.bcs=c};f.prototype.freeze=function(){this.ie?(document.detachEvent("onmousemove",this.mv),document.detachEvent("onmouseup",this.sr)):(document.removeEventListener("mousemove", +this.mv,1),document.removeEventListener("mouseup",this.sr,1))};f.prototype.toggle=function(c,a){if(this.d){if(b=this.e.body.innerHTML,this.xhtml&&(b=b.replace(/(.*)<\/span>/gi,"$1"),b=b.replace(/ class="apple-style-span"/gi,""),b=b.replace(//gi,""),b=b.replace(/
    /gi,"
    "),b=b.replace(/
    $/gi,""),b=b.replace(/^
    /gi,""),b=b.replace(/(]+[^\/])>/gi,"$1 />"),b=b.replace(/]*>(.*?)<\/b[^>]*>/gi,"$1"),b=b.replace(/]*>(.*?)<\/i[^>]*>/gi, +"$1"),b=b.replace(/]*>(.*?)<\/u[^>]*>/gi,'$1'),b=b.replace(/<(b|strong|em|i|u) style="font-weight: normal;?">(.*)<\/(b|strong|em|i|u)>/gi,"$2"),b=b.replace(/<(b|strong|em|i|u) style="(.*)">(.*)<\/(b|strong|em|i|u)>/gi,'<$4>$3'),b=b.replace(/(.*)<\/span>/gi,"$1"),b=b.replace(/(.*)<\/span>/gi,"$1"),b=b.replace(/(.*)<\/span>/gi, +"$1"),b=b.replace(/(.*)<\/span>|]*>(.*?)<\/b[^>]*>/gi,"$1")),a&&(a.innerHTML=this.obj.toggletext||"wysiwyg"),this.t.value=b,!c)this.t.style.height=this.i.height+"px",this.i.style.display="none",this.t.style.display="block",this.d=0}else{var b=this.t.value;a&&(a.innerHTML=this.obj.toggletext||"source");this.xhtml&&!this.ie&&(b=b.replace(/(.*)<\/strong>/gi,'$1'),b=b.replace(/(.*)<\/em>/gi, +'$1'));this.e.body.innerHTML=b;this.t.style.display="none";this.i.style.display="block";this.d=1}};f.prototype.post=function(){this.d&&this.toggle(1)};return{edit:f}}();TINY.cursor=function(){return{top:function(f){return T$$$()?window.event.clientY+document.documentElement.scrollTop+document.body.scrollTop:f.clientY+window.scrollY}}}(); +(function(){$_("fieldset dl").dom.hide();$_("fieldset legend").event.add("click",function(){var f=$_("fieldset dl").dom;"none"==f.css("display").trim()?f.show():f.hide()});$_("button.delete").event.add("click",function(){var f=this.parentNode.id,f=f.split("_");confirm("Are you sure you want to delete this "+f[0]+"? Deleting this item will delete all items under it. There is no undo.")});new TINY.editor.edit("editor",{id:"input",width:450,height:175,cssclass:"te",controlclass:"tecontrol",rowclass:"teheader", +dividerclass:"tedivider",controls:"bold italic underline | subscript superscript | orderedlist unorderedlist | leftalign centeralign rightalign | unformat | undo redo n image hr link unlink | cut copy paste print".split(" "),footer:!0,xhtml:!0,cssfile:"//github.timshomepage.net/meta/assets/css.php/g/css",bodyid:"editor",footerclass:"tefooter",toggle:{text:"source",activetext:"wysiwyg",cssclass:"toggle"},resize:{cssclass:"resize"}})})(); diff --git a/assets/js/meta.js b/assets/js/meta.js index f52e52a..fd2441e 100644 --- a/assets/js/meta.js +++ b/assets/js/meta.js @@ -2,7 +2,7 @@ "use strict"; - // Show/hide forms based on use + // ! Show/hide forms based on use $_("fieldset dl").dom.hide(); $_("fieldset legend").event.add('click', function(e){ var form = $_("fieldset dl").dom; @@ -12,4 +12,59 @@ : form.hide(); }); + var meta = {}; + + /** + * Deletes a genre/category/section/data item + * based on the current page context + */ + meta.delete_item = function(e) { + // Get the type/id of the item + var item_id = this.parentNode.id; + item_id = item_id.split('_'); + + var id = item_id[1]; + var type = item_id[0]; + + // Confirm deletion + var confirm_string = "Are you sure you want to delete this "+type+"? Deleting this item will delete all items under it. There is no undo."; + + var do_delete = confirm(confirm_string); + + // Call the appropriate deletion method + + + // Show status message + }; + + // ------------------------------------------------- + // ! Event binding + // ------------------------------------------------- + + // Delete Button functionality + $_("button.delete").event.add('click', meta.delete_item); + + // WYSIWYG + new TINY.editor.edit('editor',{ + id:'input', + width:450, + height:175, + cssclass:'te', + controlclass:'tecontrol', + rowclass:'teheader', + dividerclass:'tedivider', + controls:['bold','italic','underline','|','subscript','superscript','|', + 'orderedlist','unorderedlist','|','leftalign', + 'centeralign','rightalign','|','unformat','|','undo','redo','n', + 'image','hr','link','unlink','|','cut','copy','paste','print'], + footer:true, + //fonts:['Verdana','Arial','Georgia','Trebuchet MS'], + xhtml:true, + cssfile:'//github.timshomepage.net/meta/assets/css.php/g/css', + bodyid:'editor', + footerclass:'tefooter', + toggle:{text:'source',activetext:'wysiwyg',cssclass:'toggle'}, + resize:{cssclass:'resize'} + }); + }()); \ No newline at end of file diff --git a/assets/js/tinyeditor.js b/assets/js/tinyeditor.js new file mode 100755 index 0000000..d8d7f9a --- /dev/null +++ b/assets/js/tinyeditor.js @@ -0,0 +1,373 @@ +var TINY = {}; + +function T$(i) +{ + return document.getElementById(i) +} + +function T$$$() +{ + return document.all ? 1 : 0 +} + +TINY.editor = function () +{ + var c = [], + offset = -30; + c['cut'] = [1, 'Cut', 'a', 'cut', 1]; + c['copy'] = [2, 'Copy', 'a', 'copy', 1]; + c['paste'] = [3, 'Paste', 'a', 'paste', 1]; + c['bold'] = [4, 'Bold', 'a', 'bold']; + c['italic'] = [5, 'Italic', 'a', 'italic']; + c['underline'] = [6, 'Underline', 'a', 'underline']; + c['strikethrough'] = [7, 'Strikethrough', 'a', 'strikethrough']; + c['subscript'] = [8, 'Subscript', 'a', 'subscript']; + c['superscript'] = [9, 'Superscript', 'a', 'superscript']; + c['orderedlist'] = [10, 'Insert Ordered List', 'a', 'insertorderedlist']; + c['unorderedlist'] = [11, 'Insert Unordered List', 'a', 'insertunorderedlist']; + c['outdent'] = [12, 'Outdent', 'a', 'outdent']; + c['indent'] = [13, 'Indent', 'a', 'indent']; + c['leftalign'] = [14, 'Left Align', 'a', 'justifyleft']; + c['centeralign'] = [15, 'Center Align', 'a', 'justifycenter']; + c['rightalign'] = [16, 'Right Align', 'a', 'justifyright']; + c['blockjustify'] = [17, 'Block Justify', 'a', 'justifyfull']; + c['undo'] = [18, 'Undo', 'a', 'undo']; + c['redo'] = [19, 'Redo', 'a', 'redo']; + c['image'] = [20, 'Insert Image', 'i', 'insertimage', 'Enter Image URL:', 'http://']; + c['hr'] = [21, 'Insert Horizontal Rule', 'a', 'inserthorizontalrule']; + c['link'] = [22, 'Insert Hyperlink', 'i', 'createlink', 'Enter URL:', 'http://']; + c['unlink'] = [23, 'Remove Hyperlink', 'a', 'unlink']; + c['unformat'] = [24, 'Remove Formatting', 'a', 'removeformat']; + c['print'] = [25, 'Print', 'a', 'print']; + + function edit(n, obj) + { + this.n = n; + window[n] = this; + this.t = T$(obj.id); + this.obj = obj; + this.xhtml = obj.xhtml; + var p = document.createElement('div'), + w = document.createElement('div'), + h = document.createElement('div'), + l = obj.controls.length, + i = 0; + this.i = document.createElement('iframe'); + this.i.frameBorder = 0; + this.i.width = obj.width || '500'; + this.i.height = obj.height || '250'; + this.ie = T$$$(); + h.className = obj.rowclass || 'teheader'; + p.className = obj.cssclass || 'te'; + p.style.width = this.i.width + 'px'; + p.appendChild(h); + for (i; i < l; i++) + { + var id = obj.controls[i]; + if (id == 'n') + { + h = document.createElement('div'); + h.className = obj.rowclass || 'teheader'; + p.appendChild(h) + } + else if (id == '|') + { + var d = document.createElement('div'); + d.className = obj.dividerclass || 'tedivider'; + h.appendChild(d) + } + else if (id == 'font') + { + var sel = document.createElement('select'), + fonts = obj.fonts || ['Verdana', 'Arial', 'Georgia'], + fl = fonts.length, + x = 0; + sel.className = 'tefont'; + sel.onchange = new Function(this.n + '.ddaction(this,"fontname")'); + sel.options[0] = new Option('Font', ''); + for (x; x < fl; x++) + { + var font = fonts[x]; + sel.options[x + 1] = new Option(font, font) + } + h.appendChild(sel) + } + else if (id == 'size') + { + var sel = document.createElement('select'), + sizes = obj.sizes || [1, 2, 3, 4, 5, 6, 7], + sl = sizes.length, + x = 0; + sel.className = 'tesize'; + sel.onchange = new Function(this.n + '.ddaction(this,"fontsize")'); + for (x; x < sl; x++) + { + var size = sizes[x]; + sel.options[x] = new Option(size, size) + } + h.appendChild(sel) + } + else if (id == 'style') + { + var sel = document.createElement('select'), + styles = obj.styles || [ + ['Style', ''], + ['Paragraph', '

    '], + ['Header 1', '

    '], + ['Header 2', '

    '], + ['Header 3', '

    '], + ['Header 4', '

    '], + ['Header 5', '

    '], + ['Header 6', '
    '] + ], + sl = styles.length, + x = 0; + sel.className = 'testyle'; + sel.onchange = new Function(this.n + '.ddaction(this,"formatblock")'); + for (x; x < sl; x++) + { + var style = styles[x]; + sel.options[x] = new Option(style[0], style[1]) + } + h.appendChild(sel) + } + else if (c[id]) + { + var div = document.createElement('div'), + x = c[id], + func = x[2], + ex, pos = x[0] * offset; + div.className = obj.controlclass; + div.style.backgroundPosition = '0px ' + pos + 'px'; + div.title = x[1]; + ex = func == 'a' ? '.action("' + x[3] + '",0,' + (x[4] || 0) + ')' : '.insert("' + x[4] + '","' + x[5] + '","' + x[3] + '")'; + div.onclick = new Function(this.n + (id == 'print' ? '.print()' : ex)); + div.onmouseover = new Function(this.n + '.hover(this,' + pos + ',1)'); + div.onmouseout = new Function(this.n + '.hover(this,' + pos + ',0)'); + h.appendChild(div); + if (this.ie) + { + div.unselectable = 'on' + } + } + } + this.t.parentNode.insertBefore(p, this.t); + this.t.style.width = this.i.width + 'px'; + w.appendChild(this.t); + w.appendChild(this.i); + p.appendChild(w); + this.t.style.display = 'none'; + if (obj.footer) + { + var f = document.createElement('div'); + f.className = obj.footerclass || 'tefooter'; + if (obj.toggle) + { + var to = obj.toggle, + ts = document.createElement('div'); + ts.className = to.cssclass || 'toggle'; + ts.innerHTML = obj.toggletext || 'source'; + ts.onclick = new Function(this.n + '.toggle(0,this);return false'); + f.appendChild(ts) + } + if (obj.resize) + { + var ro = obj.resize, + rs = document.createElement('div'); + rs.className = ro.cssclass || 'resize'; + rs.onmousedown = new Function('event', this.n + '.resize(event);return false'); + rs.onselectstart = function () + { + return false + }; + f.appendChild(rs) + } + p.appendChild(f) + } + this.e = this.i.contentWindow.document; + this.e.open(); + var m = '', + bodyid = obj.bodyid ? " id=\"" + obj.bodyid + "\"" : ""; + if (obj.cssfile) + { + m += '' + } + if (obj.css) + { + m += '' + } + m += '' + (obj.content || this.t.value); + m += ''; + this.e.write(m); + this.e.close(); + this.e.designMode = 'on'; + this.d = 1; + if (this.xhtml) + { + try + { + this.e.execCommand("styleWithCSS", 0, 0) + } + catch (e) + { + try + { + this.e.execCommand("useCSS", 0, 1) + } + catch (e) + {} + } + } + }; + edit.prototype.print = function () + { + this.i.contentWindow.print() + }, + edit.prototype.hover = function (div, pos, dir) + { + div.style.backgroundPosition = (dir ? '34px ' : '0px ') + (pos) + 'px' + }, + edit.prototype.ddaction = function (dd, a) + { + var i = dd.selectedIndex, + v = dd.options[i].value; + this.action(a, v) + }, + edit.prototype.action = function (cmd, val, ie) + { + if (ie && !this.ie) + { + alert('Your browser does not support this function.') + } + else + { + this.e.execCommand(cmd, 0, val || null) + } + }, + edit.prototype.insert = function (pro, msg, cmd) + { + var val = prompt(pro, msg); + if (val != null && val != '') + { + this.e.execCommand(cmd, 0, val) + } + }, + edit.prototype.setfont = function () + { + execCommand('formatblock', 0, hType) + }, + edit.prototype.resize = function (e) + { + if (this.mv) + { + this.freeze() + } + this.i.bcs = TINY.cursor.top(e); + this.mv = new Function('event', this.n + '.move(event)'); + this.sr = new Function(this.n + '.freeze()'); + if (this.ie) + { + document.attachEvent('onmousemove', this.mv); + document.attachEvent('onmouseup', this.sr) + } + else + { + document.addEventListener('mousemove', this.mv, 1); + document.addEventListener('mouseup', this.sr, 1) + } + }, + edit.prototype.move = function (e) + { + var pos = TINY.cursor.top(e); + this.i.height = parseInt(this.i.height) + pos - this.i.bcs; + this.i.bcs = pos + }, + edit.prototype.freeze = function () + { + if (this.ie) + { + document.detachEvent('onmousemove', this.mv); + document.detachEvent('onmouseup', this.sr) + } + else + { + document.removeEventListener('mousemove', this.mv, 1); + document.removeEventListener('mouseup', this.sr, 1) + } + }, + edit.prototype.toggle = function (post, div) + { + if (!this.d) + { + var v = this.t.value; + if (div) + { + div.innerHTML = this.obj.toggletext || 'source' + } + if (this.xhtml && !this.ie) + { + v = v.replace(/(.*)<\/strong>/gi, '$1'); + v = v.replace(/(.*)<\/em>/gi, '$1') + } + this.e.body.innerHTML = v; + this.t.style.display = 'none'; + this.i.style.display = 'block'; + this.d = 1 + } + else + { + var v = this.e.body.innerHTML; + if (this.xhtml) + { + v = v.replace(/(.*)<\/span>/gi, '$1'); + v = v.replace(/ class="apple-style-span"/gi, ''); + v = v.replace(//gi, ''); + v = v.replace(/
    /gi, '
    '); + v = v.replace(/
    $/gi, ''); + v = v.replace(/^
    /gi, ''); + v = v.replace(/(]+[^\/])>/gi, '$1 />'); + v = v.replace(/]*>(.*?)<\/b[^>]*>/gi, '$1'); + v = v.replace(/]*>(.*?)<\/i[^>]*>/gi, '$1'); + v = v.replace(/]*>(.*?)<\/u[^>]*>/gi, '$1'); + v = v.replace(/<(b|strong|em|i|u) style="font-weight: normal;?">(.*)<\/(b|strong|em|i|u)>/gi, '$2'); + v = v.replace(/<(b|strong|em|i|u) style="(.*)">(.*)<\/(b|strong|em|i|u)>/gi, '<$4>$3'); + v = v.replace(/(.*)<\/span>/gi, '$1'); + v = v.replace(/(.*)<\/span>/gi, '$1'); + v = v.replace(/(.*)<\/span>/gi, '$1'); + v = v.replace(/(.*)<\/span>|]*>(.*?)<\/b[^>]*>/gi, '$1') + } + if (div) + { + div.innerHTML = this.obj.toggletext || 'wysiwyg' + } + this.t.value = v; + if (!post) + { + this.t.style.height = this.i.height + 'px'; + this.i.style.display = 'none'; + this.t.style.display = 'block'; + this.d = 0 + } + } + }, + edit.prototype.post = function () + { + if (this.d) + { + this.toggle(1) + } + }; + return { + edit: edit + } +}(); + +TINY.cursor = function () +{ + return { + top: function (e) + { + return T$$$() ? window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop : e.clientY + window.scrollY + } + } +}(); \ No newline at end of file diff --git a/assets/js/tinyeditor/index.html b/assets/js/tinyeditor/index.html new file mode 100755 index 0000000..17977d6 --- /dev/null +++ b/assets/js/tinyeditor/index.html @@ -0,0 +1,35 @@ + + + + +TinyEditor - JavaScript WYSIWYG Editor + + + + + + + + \ No newline at end of file diff --git a/assets/js/tinyeditor/packed.js b/assets/js/tinyeditor/packed.js new file mode 100755 index 0000000..6dbafbe --- /dev/null +++ b/assets/js/tinyeditor/packed.js @@ -0,0 +1 @@ +TINY={};function T$(i){return document.getElementById(i)}function T$$$(){return document.all?1:0}TINY.editor=function(){var c=[],offset=-30;c['cut']=[1,'Cut','a','cut',1];c['copy']=[2,'Copy','a','copy',1];c['paste']=[3,'Paste','a','paste',1];c['bold']=[4,'Bold','a','bold'];c['italic']=[5,'Italic','a','italic'];c['underline']=[6,'Underline','a','underline'];c['strikethrough']=[7,'Strikethrough','a','strikethrough'];c['subscript']=[8,'Subscript','a','subscript'];c['superscript']=[9,'Superscript','a','superscript'];c['orderedlist']=[10,'Insert Ordered List','a','insertorderedlist'];c['unorderedlist']=[11,'Insert Unordered List','a','insertunorderedlist'];c['outdent']=[12,'Outdent','a','outdent'];c['indent']=[13,'Indent','a','indent'];c['leftalign']=[14,'Left Align','a','justifyleft'];c['centeralign']=[15,'Center Align','a','justifycenter'];c['rightalign']=[16,'Right Align','a','justifyright'];c['blockjustify']=[17,'Block Justify','a','justifyfull'];c['undo']=[18,'Undo','a','undo'];c['redo']=[19,'Redo','a','redo'];c['image']=[20,'Insert Image','i','insertimage','Enter Image URL:','http://'];c['hr']=[21,'Insert Horizontal Rule','a','inserthorizontalrule'];c['link']=[22,'Insert Hyperlink','i','createlink','Enter URL:','http://'];c['unlink']=[23,'Remove Hyperlink','a','unlink'];c['unformat']=[24,'Remove Formatting','a','removeformat'];c['print']=[25,'Print','a','print'];function edit(n,a){this.n=n;window[n]=this;this.t=T$(a.id);this.obj=a;this.xhtml=a.xhtml;var p=document.createElement('div'),w=document.createElement('div'),h=document.createElement('div'),l=a.controls.length,i=0;this.i=document.createElement('iframe');this.i.frameBorder=0;this.i.width=a.width||'500';this.i.height=a.height||'250';this.ie=T$$$();h.className='teheader';p.className=a.cssclass||'te';p.style.width=this.i.width+'px';p.appendChild(h);for(i;i'],['Header 1','

    '],['Header 2','

    '],['Header 3','

    '],['Header 4','

    '],['Header 5','

    '],['Header 6','
    ']],sl=styles.length,x=0;g.className='testyle';g.onchange=new Function(this.n+'.ddaction(this,"formatblock")');for(x;x'}if(a.css){m+=''}m+=''+(a.content||this.t.value);m+='';this.e.write(m);this.e.close();this.e.designMode='on';this.d=1;if(this.xhtml){try{this.e.execCommand("styleWithCSS",0,0)}catch(e){try{this.e.execCommand("useCSS",0,1)}catch(e){}}}};edit.prototype.print=function(){this.i.contentWindow.print()},edit.prototype.hover=function(a,b,c){a.style.backgroundPosition=(c?'34px ':'0px ')+(b)+'px'},edit.prototype.ddaction=function(b,a){var i=b.selectedIndex,v=b.options[i].value;this.action(a,v)},edit.prototype.action=function(a,b,c){if(c&&!this.ie){alert('Your browser does not support this function.')}else{this.e.execCommand(a,0,b||null)}},edit.prototype.insert=function(a,b,c){var d=prompt(a,b);if(d!=null&&d!=''){this.e.execCommand(c,0,d)}},edit.prototype.setfont=function(){execCommand('formatblock',0,hType)},edit.prototype.resize=function(e){if(this.mv){this.freeze()}this.i.bcs=TINY.cursor.top(e);this.mv=new Function('event',this.n+'.move(event)');this.sr=new Function(this.n+'.freeze()');if(this.ie){document.attachEvent('onmousemove',this.mv);document.attachEvent('onmouseup',this.sr)}else{document.addEventListener('mousemove',this.mv,1);document.addEventListener('mouseup',this.sr,1)}},edit.prototype.move=function(e){var a=TINY.cursor.top(e);this.i.height=parseInt(this.i.height)+a-this.i.bcs;this.i.bcs=a},edit.prototype.freeze=function(){if(this.ie){document.detachEvent('onmousemove',this.mv);document.detachEvent('onmouseup',this.sr)}else{document.removeEventListener('mousemove',this.mv,1);document.removeEventListener('mouseup',this.sr,1)}},edit.prototype.toggle=function(b,c){if(!this.d){var v=this.t.value;if(c){c.innerHTML=this.obj.toggletext||'source'}if(this.xhtml&&!this.ie){v=v.replace(/(.*)<\/strong>/gi,'$1');v=v.replace(/(.*)<\/em>/gi,'$1')}this.e.body.innerHTML=v;this.t.style.display='none';this.i.style.display='block';this.d=1}else{var v=this.e.body.innerHTML;if(this.xhtml){v=v.replace(/<[^>]*>/g,function(a){return a.toLowerCase()});v=v.replace(/(.*)<\/span>/g,'$1');v=v.replace(/ class="apple-style-span"/g,'');v=v.replace(//g,'');v=v.replace(/
    /g,'
    ');v=v.replace(/
    $/g,'');v=v.replace(/^
    /g,'');v=v.replace(/(]+[^\/])>/gi,'$1 />');v=v.replace(/]*>(.*?)<\/b[^>]*>/g,'$1');v=v.replace(/]*>(.*?)<\/i[^>]*>/g,'$1');v=v.replace(/]*>(.*?)<\/u[^>]*>/g,'$1');v=v.replace(/<(b|strong|em|i|u) style="font-weight: normal;?">(.*)<\/(b|strong|em|i|u)>/g,'$2');v=v.replace(/<(b|strong|em|i|u) style="(.*)">(.*)<\/(b|strong|em|i|u)>/g,'<$4>$3');v=v.replace(/(.*)<\/span>/g,'$1');v=v.replace(/(.*)<\/span>/g,'$1');v=v.replace(/(.*)<\/span>/g,'$1');v=v.replace(/(.*)<\/span>|]*>(.*?)<\/b[^>]*>/g,'$1')}if(c){c.innerHTML=this.obj.toggletext||'wysiwyg'}this.t.value=v;if(!b){this.t.style.height=this.i.height+'px';this.i.style.display='none';this.t.style.display='block';this.d=0}}},edit.prototype.post=function(){if(this.d){this.toggle(1)}};return{edit:edit}}();TINY.cursor=function(){return{top:function(e){return T$$$()?window.event.clientY+document.documentElement.scrollTop+document.body.scrollTop:e.clientY+window.scrollY}}}(); \ No newline at end of file