|
| 1 | + |
| 2 | +jQuery(function($){ |
| 3 | +$(".slider").click(function() { |
| 4 | + if ($("#wrapper").hasClass("wrapper-hidder")){ |
| 5 | + $(".menu-bg").removeClass("menu-hidder"); |
| 6 | + $("#wrapper").removeClass("wrapper-hidder"); |
| 7 | + $.cookie('menu-bg-options', "show", { expires: 365, path: '/' }); |
| 8 | + } |
| 9 | + else { |
| 10 | + $(".menu-bg").addClass("menu-hidder"); |
| 11 | + $("#wrapper").addClass("wrapper-hidder"); |
| 12 | + $.cookie('menu-bg-options', "hide", { expires: 365, path: '/' }); |
| 13 | + } |
| 14 | + }); |
| 15 | + |
| 16 | + if($.cookie("menu-bg-options") == "show") { |
| 17 | + $(".menu-bg").removeClass("menu-hidder"); |
| 18 | + $("#wrapper").removeClass("wrapper-hidder"); |
| 19 | + } else if($.cookie("menu-bg-options") == "hide") { |
| 20 | + $(".menu-bg").addClass("menu-hidder"); |
| 21 | + $("#wrapper").addClass("wrapper-hidder"); |
| 22 | + } |
| 23 | + /* Login */ |
| 24 | + if((window.location.href.indexOf("index.php") != -1 && window.location.href.indexOf("index.php?") == -1 ) || $('input[name=ulogin]').length != false) { |
| 25 | + var username_text = $(".bloc > form > table > tbody > tr:nth-child(2) > td:first").html().replace(':',''); |
| 26 | + var pass_text = $(".bloc > form > table > tbody > tr:nth-child(3) > td:first").html().replace(':',''); |
| 27 | + |
| 28 | + |
| 29 | + /* Login Elements */ |
| 30 | + $("div.main-content").attr('style', 'box-shadow: none;')//Remove unwanted Shadow effect |
| 31 | + $('div.bloc h4').addClass('login_header'); //Adds classes to main-content |
| 32 | + $("div.main-content > table").removeAttr("style"); //Removes style from table. |
| 33 | + $("div.main-content > table").attr('align', 'center');//Center it. |
| 34 | + $("div.main-content > table").attr('style', 'padding: 0px 10px 1px 10px;margin-top: 80px;'); //Removes style from table + droping it little down.. |
| 35 | + $("input[name=login]").addClass('login_button');//Adding class |
| 36 | + $("div.bloc > form > table > tbody > tr:first").appendTo("div.bloc > form > table > tbody");//droping language tr down. |
| 37 | + $("div.bloc > form > table > tbody > tr:last").find('td').contents().unwrap();//Removing all Td tags |
| 38 | + $("div.bloc > form > table > tbody > tr:last").contents().wrapAll("<span style='float: left;'></span>");//Wrapping who td with that. |
| 39 | + $("div.bloc > form > table > tbody > tr:last").append("<span class='forgotp' style='float: right;'></span>"); |
| 40 | + $("div.bloc > form > table > tbody > tr:last").contents().wrapAll("<td>"); |
| 41 | + $("div.bloc > form > table > tbody > tr td > a").appendTo("div.bloc > form > table > tbody > tr:last > td > span.forgotp"); |
| 42 | + if ($(".g-recaptcha")[0]) { //There is Google Captcha |
| 43 | + $("div.bloc > form > table > tbody > tr:nth-child(4)").appendTo("div.bloc > form > table > tbody"); |
| 44 | + $("div.bloc > form > table > tbody > tr:nth-child(3) > td:first").remove(); |
| 45 | + $("div.bloc > form > table > tbody > tr:nth-child(3) > td").attr('align', 'center'); |
| 46 | + $("div.bloc > form > table > tbody > tr:nth-child(4) > td:first").attr('style', 'padding: 20px 25px 10px;'); |
| 47 | + }else { |
| 48 | + $("div.bloc > form > table > tbody > tr:nth-child(3)").appendTo("div.bloc > form > table > tbody"); |
| 49 | + $("div.bloc > form > table > tbody > tr:nth-child(3) > td:first").attr('style', 'padding: 20px 25px 10px;'); |
| 50 | + } |
| 51 | + $("div.bloc > form > table > tbody > tr:nth-child(2) > td:first").remove(); |
| 52 | + $("div.bloc > form > table > tbody > tr:first > td:first").remove(); |
| 53 | + $("div.bloc > form > table > tbody > tr:last > td:last").remove(); |
| 54 | + $('input[name=ulogin]').attr('placeholder', username_text); |
| 55 | + $('input[name=upassword]').attr('placeholder', pass_text); |
| 56 | + $("div.bloc > form > table > tbody > tr:first > td:first").attr('style', 'padding: 25px 20px 10px;'); |
| 57 | + $("input[name=ulogin]").attr('style', 'width: 320px; height: 25px; border: 1px solid rgb(204, 204, 204); padding: 3px;'); |
| 58 | + $("div.bloc > form > table > tbody > tr:nth-child(2) > td:first").attr('style', 'padding: 5px 20px;'); |
| 59 | + $("input[name=upassword]").attr('style', 'width: 320px; height: 25px; border: 1px solid rgb(204, 204, 204); padding: 3px;'); |
| 60 | + $("div.bloc > form > table > tbody > tr:last > td:first").attr('style', 'text-align: center;'); |
| 61 | + $("div.bloc").attr('style', 'background-color: #fff;'); |
| 62 | + } |
| 63 | + |
| 64 | + //Replacing images/ path with themes/Flat/images/ path |
| 65 | + $('img').each(function() { |
| 66 | + if ($(this).attr('src') == 'images/edit.png') { |
| 67 | + $(this).attr('src', 'themes/Flat/images/edit.png'); |
| 68 | + }else if ($(this).attr('src') == 'images/file_size.png') { |
| 69 | + $(this).attr('src', 'themes/Flat/images/file_size.png'); |
| 70 | + }else if ($(this).attr('src') == 'images/ftp.png') { |
| 71 | + $(this).attr('src', 'themes/Flat/images/ftp.png'); |
| 72 | + }else if ($(this).attr('src') == 'images/install.png') { |
| 73 | + $(this).attr('src', 'themes/Flat/images/install.png'); |
| 74 | + }else if ($(this).attr('src') == 'images/txt.png') { |
| 75 | + $(this).attr('src', 'themes/Flat/images/txt.png'); |
| 76 | + }else if ($(this).attr('src') == 'images/log.png') { |
| 77 | + $(this).attr('src', 'themes/Flat/images/log.png'); |
| 78 | + }else if ($(this).attr('src') == 'images/rsync.png') { |
| 79 | + $(this).attr('src', 'themes/Flat/images/rsync.png'); |
| 80 | + } |
| 81 | + }); |
| 82 | + |
| 83 | + $(".unclickmmddyyyy").click(function() { |
| 84 | + $(".ddmmyyyy").hide(); |
| 85 | + $(".mmddyyyy").show(); |
| 86 | + $(this).hide(); |
| 87 | + $(".clickedmmddyyyy").show(); |
| 88 | + $(".unclickddmmyyyy").show(); |
| 89 | + $(".clickedddmmyyyy").hide(); |
| 90 | + $.cookie('dateview', "ddmmyyyy", { expires: 365, path: '/' }); |
| 91 | + return false; |
| 92 | + }); |
| 93 | + |
| 94 | + $(".unclickddmmyyyy").click(function() { |
| 95 | + $(".mmddyyyy").hide(); |
| 96 | + $(".ddmmyyyy").show(); |
| 97 | + $(this).hide(); |
| 98 | + $(".clickedddmmyyyy").show(); |
| 99 | + $(".unclickmmddyyyy").show(); |
| 100 | + $(".clickedmmddyyyy").hide(); |
| 101 | + $.cookie('dateview', "mmddyyyy", { expires: 365, path: '/' }); |
| 102 | + return false; |
| 103 | + }); |
| 104 | + |
| 105 | + if($.cookie("dateview") == "ddmmyyyy") { |
| 106 | + $(".ddmmyyyy").hide(); |
| 107 | + $(".mmddyyyy").show(); |
| 108 | + $(".clickedmmddyyyy").show(); |
| 109 | + $(".unclickddmmyyyy").show(); |
| 110 | + $(".unclickmmddyyyy").hide(); |
| 111 | + $(".clickedddmmyyyy").hide(); |
| 112 | + } |
| 113 | + else if($.cookie("dateview") == "mmddyyyy") { |
| 114 | + $(".mmddyyyy").hide(); |
| 115 | + $(".ddmmyyyy").show(); |
| 116 | + $(".clickedddmmyyyy").show(); |
| 117 | + $(".unclickmmddyyyy").show(); |
| 118 | + $(".unclickddmmyyyy").hide(); |
| 119 | + $(".clickedmmddyyyy").hide(); |
| 120 | + } else { |
| 121 | + $(".mmddyyyy").hide(); |
| 122 | + $(".ddmmyyyy").show(); |
| 123 | + $(".clickedddmmyyyy").show(); |
| 124 | + $(".unclickmmddyyyy").show(); |
| 125 | + $(".unclickddmmyyyy").hide(); |
| 126 | + $(".clickedmmddyyyy").hide(); |
| 127 | + }; |
| 128 | + |
| 129 | + //sidebar// |
| 130 | + $('div.menu li:has(ul)').addClass('treeview'); |
| 131 | + $('div.menu li:has(ul) > a').append('<i class="fa fa-angle-left pull-right"></i>'); |
| 132 | + $('div.menu ul ul').addClass('treeview-sub'); |
| 133 | + $('.treeview > a').addClass('treeview-a'); |
| 134 | + |
| 135 | + $.sidebarMenu = function(menu) { |
| 136 | + var animationSpeed = 300; |
| 137 | + |
| 138 | + $(menu).on('click', 'li a', function(e) { |
| 139 | + var $this = $(this); |
| 140 | + var checkElement = $this.next(); |
| 141 | + |
| 142 | + if (checkElement.is('.treeview-sub') && checkElement.is(':visible')) { |
| 143 | + checkElement.slideUp(animationSpeed, function() { |
| 144 | + checkElement.removeClass('menu-open'); |
| 145 | + }); |
| 146 | + |
| 147 | + checkElement.parent("li").removeClass("active"); |
| 148 | + } |
| 149 | + |
| 150 | + //If the menu is not visible |
| 151 | + else if ((checkElement.is('.treeview-sub')) && (!checkElement.is(':visible'))) { |
| 152 | + //Get the parent menu |
| 153 | + var parent = $this.parents('ul').first(); |
| 154 | + //Close all open menus within the parent |
| 155 | + var ul = parent.find('ul:visible').slideUp(animationSpeed); |
| 156 | + //Remove the menu-open class from the parent |
| 157 | + ul.removeClass('menu-open'); |
| 158 | + //Get the parent li |
| 159 | + var parent_li = $this.parent("li"); |
| 160 | + |
| 161 | + //Open the target menu and add the menu-open class |
| 162 | + checkElement.slideDown(animationSpeed, function() { |
| 163 | + //Add the class active to the parent li |
| 164 | + checkElement.addClass('menu-open'); |
| 165 | + parent.find('li.active').removeClass('active'); |
| 166 | + parent_li.addClass('active'); |
| 167 | + }); |
| 168 | + } |
| 169 | + |
| 170 | + //if this isn't a link, prevent the page from being redirected |
| 171 | + if (checkElement.is('.treeview-sub')) { |
| 172 | + e.preventDefault(); |
| 173 | + } |
| 174 | + }); |
| 175 | + } //sidebarMenu end. |
| 176 | + |
| 177 | + //GOT HELP// |
| 178 | + $('li.treeview').each(function() { |
| 179 | + $('<li class="copied"></li>').html($(this).children('a').clone()).prependTo($(this).children('ul')).find('> a > span').html('Overview'); |
| 180 | + }); |
| 181 | + $(".copied > a").removeClass('admin_menu_link_selected'); |
| 182 | + $(".copied > a").removeClass('user_menu_link_selected'); |
| 183 | + $(".copied > a > span").removeAttr('data-icon_path'); |
| 184 | + $(".treeview > a").removeClass('treeview-a'); |
| 185 | + $('.treeview').each(function() { |
| 186 | + var $linked = $(this); |
| 187 | + if ($linked.find('.admin_menu_link_selected').length > 0) { |
| 188 | + $linked.addClass('active'); |
| 189 | + } else if ($linked.find('.user_menu_link_selected').length > 0) { |
| 190 | + $linked.addClass('active'); |
| 191 | + } |
| 192 | + }); //treeview.each end. |
| 193 | + $.sidebarMenu($('.menu')); |
| 194 | + if(window.location.href.indexOf("home.php?m=") > -1) { |
| 195 | + $(".menu").prepend('<div class="avatar-cover"><span class="avatar-username"></span><span class="avatar-status"><i class="fa fa-circle"></i>Online</span><label class="edit_avatar"><i class="fa fa-camera"></i><input class="avatarinput" type="file" /></label><span id="remove_avatar"><i class="fa fa-trash"></i></span></div>'); |
| 196 | + $(".avatar-username").text($("li.treeview > a.user_menu_link span.username").text()); |
| 197 | + |
| 198 | + if(localStorage.Avatar) { |
| 199 | + var img = new Image(); |
| 200 | + img.src = localStorage.Avatar; |
| 201 | + |
| 202 | + $(".avatar-cover").prepend(img); |
| 203 | + $(".avatar-cover > img").attr('id', 'avatar'); |
| 204 | + } else { |
| 205 | + $(".menu .avatar-cover").prepend('<img id="avatar" src="themes/Flat/images/default_avatar.png">'); |
| 206 | + } |
| 207 | + |
| 208 | + $("#avatar").attr('style', 'border-radius: 100%;width: 64px;height: 64px;'); |
| 209 | + } //href index of end. |
| 210 | + |
| 211 | + var nodes = document.getElementById('submenu_0').getElementsByTagName('span'); |
| 212 | + |
| 213 | + for(var i=0; i<nodes.length; i++) { |
| 214 | + iconPath = nodes[i].getAttribute("data-icon_path"); |
| 215 | + if(typeof iconPath != "undefined" && iconPath != "") { |
| 216 | + nodes[i].style.background = "url("+iconPath+") 0% 50% / 16px 16px no-repeat scroll transparent"; |
| 217 | + nodes[i].style.padding = "5px 0 5px 25px"; |
| 218 | + } |
| 219 | + } |
| 220 | + |
| 221 | + |
| 222 | + $(".copied > a > span").css("background", ""); |
| 223 | + $(".copied > a > span").css("padding", ""); |
| 224 | + |
| 225 | + //You might want to do if check to see if localstorage set for theImage here |
| 226 | + |
| 227 | + $('body').on('click', '#remove_avatar',function(){ |
| 228 | + localStorage.removeItem("Avatar"); |
| 229 | + $("#avatar").remove(); |
| 230 | + $(".menu .avatar-cover").prepend('<img id="avatar" src="themes/Flat/images/default_avatar.png">'); |
| 231 | + $("#avatar").attr('style', 'border-radius: 100%;width: 64px;height: 64px;'); |
| 232 | + }); //body.on.click end. |
| 233 | + |
| 234 | + $("body").on("change",".avatarinput",function(){ |
| 235 | + //Equivalent of getElementById |
| 236 | + var fileInput = $(this)[0];//returns a HTML DOM object by putting the [0] since it's really an associative array. |
| 237 | + var file = fileInput.files[0]; //there is only '1' file since they are not multiple type. |
| 238 | + |
| 239 | + var reader = new FileReader(); |
| 240 | + reader.onload = function(e) { |
| 241 | + // Create a new image. |
| 242 | + var img = new Image(); |
| 243 | + |
| 244 | + img.src = reader.result; |
| 245 | + localStorage.Avatar = reader.result; //stores the image to localStorage |
| 246 | + $("#avatar").remove(); |
| 247 | + $(".avatar-cover").prepend(img); |
| 248 | + $(".avatar-cover > img").attr('id', 'avatar'); |
| 249 | + $("#avatar").attr('style', 'border-radius: 100%;width: 64px;height: 64px;'); |
| 250 | + } |
| 251 | + |
| 252 | + reader.readAsDataURL(file);//attempts to read the file in question. |
| 253 | + }); //body.on.change end. |
| 254 | + |
| 255 | +}); //document.ready end |
0 commit comments