/** * THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ $(function() { // Initialize Init(); /********************************** Settings and CSS junk ***********************************/ $('head').append(''); /*var tinySettings = { base : '../../wp-includes/js/tinymce',//'portal/tiny_mce.js', suffix : "", script_url : '../../wp-includes/js/tinymce/tiny_mce.js',//'portal/tiny_mce.js', //plugins: "inlinepopups", ref : {plugins:"inlinepopups,spellchecker,tabfocus,paste,media,fullscreen,wordpress,wpeditimage,wpgallery,wplink,wpdialogs",theme:"advanced",language:"en"}, load_ext : function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}, theme: "advanced", theme_advanced_buttons1 : "bold,italic,underline,strikethrough," + "separator,cut,copy,paste,separator,bullist,numlist,separator,undo,redo,separator,link,unlink,image", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", width: "100%", height: 250, content_css : "content.css", };*/ /*tinyMCEPreInit = { base : "http://localhost/15gl2012/wp-includes/js/tinymce", suffix : "", query : "ver=345-20111127", mceInit : {'content1':{mode:"exact",width:"100%",theme:"advanced",skin:"wp_theme",language:"en",spellchecker_languages:"+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",theme_advanced_statusbar_location:"bottom",theme_advanced_resizing:true,theme_advanced_resize_horizontal:false,dialog_type:"modal",formats:{ alignleft : [ {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'left'}}, {selector : 'img,table', classes : 'alignleft'} ], aligncenter : [ {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'center'}}, {selector : 'img,table', classes : 'aligncenter'} ], alignright : [ {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'right'}}, {selector : 'img,table', classes : 'alignright'} ], strikethrough : {inline : 'del'} },relative_urls:false,remove_script_host:false,convert_urls:false,remove_linebreaks:true,gecko_spellcheck:true,keep_styles:false,entities:"38,amp,60,lt,62,gt",accessibility_focus:true,tabfocus_elements:"major-publishing-actions",media_strict:false,paste_remove_styles:true,paste_remove_spans:true,paste_strip_class_attributes:"all",paste_text_use_dialog:true,extended_valid_elements:"article[*],aside[*],audio[*],canvas[*],command[*],datalist[*],details[*],embed[*],figcaption[*],figure[*],footer[*],header[*],hgroup[*],keygen[*],mark[*],meter[*],nav[*],output[*],progress[*],section[*],source[*],summary,time[*],video[*],wbr",wpeditimage_disable_captions:false,wp_fullscreen_content_css:"http://localhost/15gl2012/wp-includes/js/tinymce/plugins/wpfullscreen/css/wp-fullscreen.css",plugins:"inlinepopups,spellchecker,tabfocus,paste,media,fullscreen,wordpress,wpeditimage,wpgallery,wplink,wpdialogs",content_css:"http://localhost/15gl2012/wp-content/themes/aisle/editor-style.css",elements:"content1",wpautop:true,apply_source_formatting:false,theme_advanced_buttons1:"bold,italic,strikethrough,|,bullist,numlist,blockquote,|,justifyleft,justifycenter,justifyright,|,link,unlink,wp_more,|,spellchecker,fullscreen,wp_adv",theme_advanced_buttons2:"formatselect,underline,justifyfull,forecolor,|,pastetext,pasteword,removeformat,|,charmap,|,outdent,indent,|,undo,redo,wp_help",theme_advanced_buttons3:"",theme_advanced_buttons4:"",editor_selector:"apm-editor",height:"150"},'content':{elements:"content",wpautop:true,remove_linebreaks:true,apply_source_formatting:false,theme_advanced_buttons1:"bold,italic,strikethrough,|,bullist,numlist,blockquote,|,justifyleft,justifycenter,justifyright,|,link,unlink,wp_more,|,spellchecker,wp_fullscreen,wp_adv,|,scn_button",theme_advanced_buttons2:"formatselect,underline,justifyfull,forecolor,|,pastetext,pasteword,removeformat,|,charmap,|,outdent,indent,|,undo,redo,wp_help",theme_advanced_buttons3:"",theme_advanced_buttons4:""}}, qtInit : {'content':{id:"content",buttons:"strong,em,link,block,del,ins,img,ul,ol,li,code,more,spell,close,fullscreen"},'replycontent':{id:"replycontent",buttons:"strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close"}}, ref : {plugins:"inlinepopups,spellchecker,tabfocus,paste,media,fullscreen,wordpress,wpeditimage,wpgallery,wplink,wpdialogs",theme:"advanced",language:"en"}, load_ext : function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');} };*/ /********************************** Dashboard initialization ***********************************/ function Init() { // Initialize dialogs initDialogs(); // Portlet and sort related CSS classes var sortClasses = "ui-widget ui-widget-content ui-helper-clearfix"; // Set every column segment with h5 element as a sortable widget $('.column:has(h5)').each(function() { var s = $(this); var p = s.parentsUntil('section').parent(); var h = s.children('h5:first').eq(0); if(!p.hasClass('ui-widget')) p.addClass(sortClasses); // Function icons h.addClass('ui-widget-header') .prepend('') .prepend('') .prepend(''); // Need this to drag not highlight h.disableSelection(); // Interaction cues h.css('cursor', 'move'); $('.ui-icon').css('cursor', 'pointer'); // Wrap control stuff (like icons and headers) in a widget-header div // and the rest in a widget-content div s.children().not('img[alt="icon"], .ui-widget-header, .ui-icon') .wrapAll('
'); s.children().not('widget-content').wrapAll('
'); }); // Group sortable widgets in each section to one sort-area $('section').has('.column').each(function() { $(this).children().not('header,hr') .wrapAll('
'); }); // Trigger control initialization setControls(); } /********************************** Dialog boxes ***********************************/ function initDialogs() { // Close widget dialog $('article').append(''); // Config widget dialog $('article').append(''); // Create and destroy these dialogs to hide them $('#dialog-confirm-close-widget').dialog("destroy"); $('#dialog-config-widget').dialog("destroy"); } /********************************** Widget controls ***********************************/ // Control icons function setControls(ui) { ui = (ui)? ui : $('.ui-icon'); ui.click(function() { var b = $(this); var p = b.parentsUntil('.column').parent(); var i = p.children('img[alt="icon"]:first').eq(0); var h = p.children('.ui-widget-header h5:first').eq(0); // Control functionality switch(b.attr('title').toLowerCase()) { case 'config': widgetConfig(b, p); break; case 'toggle': widgetToggle(b, p, i); break; case 'close': widgetClose(b, p); break; } }); } // Toggle widget function widgetToggle(b, p, i) { // Change the + into - and visa versa b.toggleClass('ui-icon-minus').toggleClass('ui-icon-plus'); // Turn the big icon into a small one or visa versa if(i.hasClass('icon')) i.switchClass('icon', 'ticon', '300'); else i.switchClass('ticon', 'icon', '300'); // Show/Hide widget content p.children('.widget-content').eq(0).toggle(300); } // Modify widget function widgetConfig(w, p) { // Input elements in the dialog var dt = $('#widget-title-text'); var dc = $('#widget-content-text'); var du = $('#widget-icon-text'); // Widget elements to change var wt = p.children('h5:first').eq(0); var wc = p.children('.widget-content').eq(0); // If there is no icon on the widget, there's nothing to change var wi = p.children('img[alt="icon"]:first'); if(wi.length > 0) { wi = p.children('img[alt="icon"]:first').eq(0); $('#icon-field').show(); } else { $('#icon-field').hide(); } $("#dialog-config-widget").dialog({ resizable: false, modal: true, width: 500, open: function() { if(wi != null) du.val(wi.attr('src')); dt.val(wt.text()); dc.val(wc.html()); // Initialize TinyMCE tinyMCE.init({ // mode : "exact", theme : "advanced", // skin:"wp_theme", // , plugins : "emotions,spellchecker,advhr,insertdatetime,preview", // Theme options - button# indicated the row# only theme_advanced_buttons1 : "bold,italic,underline,|,fontsizeselect,formatselect", theme_advanced_buttons2 : "bullist,numlist,outdent,indent,|,link,unlink,anchor,image", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", width: "100%", height: 250, content_css : "content.css", theme_advanced_resizing : true }); //jQuery("#widget-content-text").addClass("apm-editor"); //if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.execCommand ) == "function" ) { tinyMCE.execCommand("mceAddControl", false, "widget-content-text"); //} //initTiny(dc); }, buttons: { "Save changes": function(e, ui) { // Some widgets don't have an icon if(wi.length > 0) { if(notEmpty(du.val())) wi.attr('src', du.val()); } // Remove editor (also gets content from TinyMCE back to textarea) closeTiny(dc); // Update if(notEmpty(dc.val())) wc.html(dc.val()); // Careful here, don't wanna lose the control icons if(notEmpty(dt.val())) { var ci = wt.children('span.ui-icon'); wt.html(dt.val()); // Reset controls wt.prepend(ci); setControls(ci); } $(this).dialog("close"); }, Cancel: function() { // Destroy TinyMCE closeTiny(dc); $(this).dialog("close"); } } }); } // Close widget with dialog function widgetClose(w, p) { $("#dialog-confirm-close-widget").dialog({ resizable: false, modal: true, buttons: { "Close widget": function() { p.toggle('slide', {}, 500, function() { p.remove(); }); $(this).dialog("close"); }, Cancel: function() { $(this).dialog("close"); } } }); } /********************************** Sort functionality ***********************************/ $(".sort-area").sortable({ connectWith: ".sort-area", opacity: 0.6, helper: 'clone', dropOnEmpty: true }); /********************************** Helpers ***********************************/ function notEmpty(t) { if(t) { if($.trim(t) != "") return true; } return false } function initTiny(t, s) { t.tinymce(s); } function closeTiny(t) { var e = t.attr('id'); t.val(tinyMCE.get(e).getContent()); tinyMCE.execCommand('mceRemoveControl', false, e); } }); /* WTF is juice?! - Dave Chappelle */